<%--
  Created by IntelliJ IDEA.
  User: linnanxiang
  Date: 2020/12/21
  Time: 10:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>工作日每小时租赁情况</title>
    <script src="js/jquery.min.js"></script>
    <script src="js/echarts.min.js"></script>

  </head>

  <body>
  <div id="main" style="width: 1400px;height:700px;"></div>
<script>
  $(document).ready(function (){

    myChart = echarts.init(document.getElementById('main'));
    option = {
      title: {
        text: '工作日每小时租赁情况',
        textStyle: {
          fontSize: 40,
          fontFamily:'华文行楷',
          fontWeight: '100',
          align: 'center',
          color: '#080b30',
        },
      },
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'cross',
          label: {
            backgroundColor: '#6a7985'
          }
        }
      },
      legend: {
        data: ['非注册用户', '注册用户', '总租车人数']
      },
      toolbox: {
        feature: {
          saveAsImage: {}
        }
      },
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      },
      xAxis: [  {
        type: 'category',
        boundaryGap: false,
        data: []
      }],
      yAxis: [
        {
          type: 'value'
        }
      ],
      series: [ {
        name: '非注册用户',
        type: 'line',
        stack: '总量',
        areaStyle: {},
        data: []
      },
        {
          name: '注册用户',
          type: 'line',
          stack: '总量',
          areaStyle: {},
          data: []
        },
        {
          name: '总租车人数',
          type: 'line',
          stack: '总量',
          areaStyle: {},
          data: []
        }]
    };

    var dates=[];
    var casual=[];
    var registered=[];
    var count=[];


    $.ajax({
      url: 'phwork',
      method: "get",
      type: "json",
      success: function (data) {

       if (data){
           for (var i=0;i<data.length;i++){
               dates.push(data[i].hour);
           }
           for (var i=0;i<data.length;i++){
               casual.push(data[i].casual);
               registered.push(data[i].registered);
               count.push(data[i].count);
           }
       }

        option.xAxis[0].data=dates;

       option.series[0].data=casual;
        option.series[1].data=registered;

        option.series[2].data=count;

        console.log(option)
        myChart.setOption(option);
      },
      error: function (errMsg) {
        console.error(errMsg)
      }
    });

  })


</script>


  </body>
</html>
